/**
 * MapPanel.java
 * 
 * Displays the setup information after a new world has been created. Displayed to the user after clicking 
 * view world from the view menu item. 
 *
 */
package com.swin.energy;

import java.awt.BorderLayout;
import java.awt.ComponentOrientation;
import java.awt.GridLayout;
import java.awt.Label;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

public class MapPanel extends JPanel {

	private JLabel titleLabel;
	private JLabel numOfRegions;
	private JLabel numOfHouses;
	private JLabel numOfAppliances;
	private JLabel totalNumOfHouses;
	private JLabel totalNumOfAppliances;
	private JPanel topPanel = new JPanel();
	private static final long serialVersionUID = -810066202944395648L;

	public MapPanel() {
		this.setLayout(new BorderLayout());

		this.titleLabel = new JLabel();
		this.numOfRegions = new JLabel("Number of regions:");
		this.numOfHouses = new JLabel("Max number of Houses per region:");
		this.numOfAppliances = new JLabel("Max number of appliances per house:");
		this.totalNumOfAppliances = new JLabel("Total number of appliances:");
		this.totalNumOfHouses = new JLabel("Total number of housese:");
		this.topPanel.setLayout(new GridLayout(6, 1));

		this.add(topPanel, BorderLayout.NORTH);
		this.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
		this.setBorder(new EmptyBorder(20, 20, 20, 20));
	}

	public void displayInitialisation(Initialisation init) {
		topPanel.removeAll();
		titleLabel.setText(init.getName());

		topPanel.add(titleLabel);
		addLableAndText(numOfRegions, Integer.toString(init.getNosOfRegions()));
		addLableAndText(numOfHouses,
				Integer.toString(init.getMaxNumberOfHouses()));
		addLableAndText(numOfAppliances,
				Integer.toString(init.getNumberOfAppliances()));

		addLableAndText(totalNumOfAppliances,
				Integer.toString(init.getTotalNumberOfAppliances()));
		addLableAndText(totalNumOfHouses,
				Integer.toString(init.getTotalNumberOfHouses()));
		topPanel.revalidate();
	}

	void addLableAndText(JLabel label, String str) {
		JPanel p = new JPanel();
		p.add(label);
		p.add(new Label(str));
		topPanel.add(p);
	}
}